home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / rvga01.zip / KEYB.C < prev    next >
C/C++ Source or Header  |  1994-08-10  |  1KB  |  77 lines

  1. /**********************************************
  2.  
  3.     Keyboard Routines
  4.     Copyright Reglage (C) 1994
  5.  
  6.     Keyb.c
  7.  
  8. **********************************************/
  9.  
  10. #include "keyb.h"
  11.  
  12.  
  13. /**********************************************
  14.  
  15.     Returns true if Keypress Waiting
  16.  
  17. **********************************************/
  18.  
  19. UBYTE K_KbHit(void)
  20. {
  21.     asm    xor    ax,ax;
  22.     asm    mov    es,ax;
  23.     asm    mov    ax,[es:0x41a];    //    KbHead
  24.     asm    sub    ax,[es:0x41c];    //    KbTail
  25.  
  26.     return (_AX==0);
  27. }
  28.  
  29.  
  30. /**********************************************
  31.  
  32.     Remove (eat) All Keys from Keyboard Buffer
  33.  
  34. **********************************************/
  35.  
  36. void K_EatKbHit(void)
  37. {
  38. //    *(unsigned far *)0x0000041a=*(unsigned far *)0x0000041c;
  39.  
  40.     asm    xor    ax,ax;
  41.     asm    mov    es,ax;
  42.     asm    mov    ax,es:[0x41c];
  43.     asm    mov    es:[0x41a],ax;
  44. }
  45.  
  46. /**********************************************
  47.  
  48.     Store KbHit in Keyboard Buffer
  49.  
  50. **********************************************/
  51.  
  52. UBYTE K_StoreKbHit(UWORD KEY)
  53. {
  54.     asm    mov    ah,0x05;
  55.     asm    mov    cx,KEY;
  56.     asm    int    0x16;
  57.  
  58.     return _AL;
  59. }
  60.  
  61.  
  62. /**********************************************
  63.  
  64.     Finally...get a KeyPress
  65.  
  66. **********************************************/
  67.  
  68. UWORD K_KeyPress(void)
  69. {
  70.     while(K_KbHit());
  71.  
  72.     asm    mov    ah,0x10;
  73.     asm    int    0x16;
  74.  
  75.     return _AX;
  76. }
  77.